/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.server.modules.sys.entity.loan;

import com.fasterxml.jackson.annotation.JsonBackReference;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

import com.server.common.persistence.TreeEntity;

/**
 * 贷款类型表Entity
 * @author 王磊
 * @version 2016-09-13
 */
public class LoanType extends TreeEntity<LoanType> {
	
	private static final long serialVersionUID = 1L;
	protected LoanType parent;		// parent_id
	protected String parentIds;		// parent_ids
	protected String name;		// 名称
	protected String iconUrl;		// 图标
	protected String orderids;		// 排序
	
	public LoanType() {
		super();
	}

	public LoanType(String id){
		super(id);
	}

	@JsonBackReference
	@NotNull(message="parent_id不能为空")
	public LoanType getParent() {
		return parent;
	}

	public void setParent(LoanType parent) {
		this.parent = parent;
	}
	
	@Length(min=0, max=2000, message="parent_ids长度必须介于 0 和 2000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@Length(min=1, max=255, message="名称长度必须介于 1 和 255 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	

	
	@Length(min=1, max=255, message="图标长度必须介于 1 和 255 之间")
	public String getIconUrl() {
		return iconUrl;
	}

	public void setIconUrl(String iconUrl) {
		this.iconUrl = iconUrl;
	}
	
	@Length(min=1, max=11, message="排序长度必须介于 1 和 11 之间")
	public String getOrderids() {
		return orderids;
	}

	public void setOrderids(String orderids) {
		this.orderids = orderids;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}